﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 实验一._3
{
    class Program
    {
        static void Main(string[] args)
        {
            double PI,f=-1.0,sum=0.0;
            int n,i=1;  
            Console.WriteLine("输入项:");
            string s = Console.ReadLine();
            n = int.Parse(s);
            while(i!=n)
            {
                sum+= 1 / ((2 * i - 1) * Math.Pow(f,i-1));
                i++;
            }
            PI = sum * 4;
            Console.WriteLine($"第{n}项的PI近似值为{PI}");
            Console.ReadKey();
        }
    }
}
